package com.assets.room.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.assets.room.entity.ReceivesDetail;
import com.assets.room.entity.ReceivesReapply;

import java.util.List;

@Dao
public interface ReceivesDetailDao {

    @Insert
    void insertReceivesDetail(ReceivesDetail receivesDetail);

    @Insert
    void insertReceivesDetail(List<ReceivesDetail> receivesDetail);

    @Query("DELETE FROM t_asset_receives_receivesdetail")
    void deleteAllData();

    @Query("SELECT * FROM  t_asset_receives_receivesdetail WHERE asset_id = :asset_number AND isreturn = :isreturn")
    ReceivesDetail getByTowReceivesDetail(String asset_number, String isreturn);

    @Query("SELECT * FROM t_asset_receives_receivesdetail")
    List<ReceivesDetail> getAllReceivesDetail();

    @Query("SELECT * FROM t_asset_receives_receivesdetail WHERE receives_id = :receives_id")
    List<ReceivesDetail> getReceivesDetailById(Long receives_id);
    @Query("SELECT * FROM t_asset_receives_receivesdetail WHERE asset_id = :asset_id")
    List<ReceivesDetail> getNameById(String asset_id);

    @Query("SELECT asset_id FROM t_asset_receives_receivesdetail WHERE receives_id = :receives_id")
    List<String> getAssetById(String receives_id);

    @Query("SELECT receives_id FROM t_asset_receives_receivesdetail WHERE asset_id = :asset_id")
    String getIdById(String asset_id);

    @Query("SELECT receives_id FROM t_asset_receives_receivesdetail WHERE asset_id = :asset_id")
    String getAssetByIds(String asset_id);

    @Query("UPDATE t_asset_receives_receivesdetail SET is_flag = :is_flag")
    void updateFlag(String is_flag);

    @Query("SELECT * FROM t_asset_receives_receivesdetail WHERE is_flag = :is_flag")
    List<ReceivesDetail> getReceivesDetailByFlag(String is_flag);

//    @Query("SELECT * FROM t_asset_receives_receivesdetail WHERE receives_id = :receives_id")
//    List<ReceivesDetail> getReceivesDetailById(Long receives_id);

    @Query("UPDATE t_asset_receives_receivesdetail SET is_flag = :is_flag, isreturn = :isreturn WHERE asset_id = :asset_id")
    void updateFlag(String is_flag, String isreturn, String asset_id);
}
